import { Form } from 'antd-mini/es/Form/form';
import { UserInfoType } from '../../types/index';
import api from '../../utils/api';

Page({
  data: {},
  form: new Form(),
  onLoad() {},
  handleRef(ref) {
    this.form.addItem(ref);
  },
  async submit() {
    const values = await this.form.submit();
    const res: UserInfoType = await api.updateUser(values);
    if (res?.id) {
      // console.log('修改成功');
      my.showToast({
        content: '修改成功',
        type: 'success',
        duration: 2000,
        success: () => {
          my.navigateTo({
            url: `/pages/login/login`
          });
        }
      })
    }
  }
});
